package BIll;

import java.util.List;

import net.sf.json.JSONArray;
import Dao.DAORoom;
import Entity.Room;
import tool.DaoFactory;

public class BLLRoom extends BLLAbstract{
	private DaoFactory daoFactory = DaoFactory.getDaoFactory();
	DAORoom daoRoom = daoFactory.getInstance(DAORoom.class);
	
	
	public List<Room> queryRoomInfo(int roomid){
		List<Room> room = daoRoom.queryRoomInfo(roomid);
		return room;
	}
	
	
	public List<Room> queryRoomInfo(){
		List<Room> list = daoRoom.queryRoomInfo();
		return list;
	}

	public boolean addUser(int roomid){
		boolean b = daoRoom.addUser(roomid);
		return b;
	}
	

	public boolean updateRoomInfo(int roomid,int roomstatus,int roomtype,int roomprice){
		Room room = new Room();
		room.setRoomid(roomid);
		room.setRoomprice(roomprice);
		room.setRoomstatus(roomstatus);
		room.setRoomtype(roomtype);
		boolean b = daoRoom.updateRoomInfo(room);
		return b;
	}
	

	public List<Room> queryRoomForEmpty(int roomtype,int type){
		List<Room> list = null;
		if (type==2) {
			list = daoRoom.queryRoomForEmptyByType(roomtype);
		}else {
			list = daoRoom.queryAllRoomForEmpty();
		}
		return list;
	}

	
	public int checkOut(int roomid){
		int match = daoRoom.checkOut(roomid);
		return match;
	}
}